<?php

namespace Biz\model\activity;

use Biz\model\GoodsBasicInfo as mGoodsBasicInfo;
use Doraemon\pockets\datebase\BaseDbModel;
use Doraemon\tools\ImgUrl;

class OutCouponRecord extends BaseDbModel
{
    const _CONFIG_FILE_ = 'db_shop';

    const _CONFIG_SELECT_ = 'db_activity';

    const _DATABASE_ = 'shop_activity';

    const _TABLE_NAME = 'outcoupon_record';


    //领取状态
    const STATUS_WAIT_SEND = 1;//待发放
    const STATUS_SUCCESS = 2;//领取成功
    const STATUS_FAIL = 3;//领取失败


    public static function getRecordByMobile($outCouponId, $mobile)
    {
        $info = self::get('*', ['outcoupon_id' => $outCouponId, 'mobile' => $mobile]);

        return $info;
    }

    public static function createOrEdit($id, $data)
    {
        if ($id > 0) {

            self::update($data, ['id' => $id]);

            return $id;
        } else {

            $data['addtime'] = date('Y-m-d H:i:s');

            self::insert($data);

            return self::id();
        }
    }

    public static function upStatusSuccess($id)
    {
        self::update(['status' => self::STATUS_SUCCESS], ['id' => $id]);
    }


}